﻿CREATE PROCEDURE [dbo].[Course_Select]
	@ID INT = NULL, 
    @Name NVARCHAR(50) = NULL, 
    @Description NVARCHAR(MAX) = NULL, 
    @PreReq NVARCHAR(50) = NULL,
	@Department NVARCHAR(50) = NULL

	AS

	Select *
	From[Courses]
	where
	(
	    ( @ID IS NULL OR ID = @ID ) AND 
		( @Name IS NULL OR Name LIKE @Name + '%' ) AND
		( @Description  IS NULL OR Description LIKE @Description + '%' ) AND
		( @PreReq IS NULL OR PreReq LIKE @PreReq + '%' )AND
		( @Department  IS NULL OR Department LIKE @Department + '%' )

	)